package com.huang.controller;

import com.huang.pojo.User;
import com.huang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {


    @Autowired
    UserService service;


    //查询demo_user的所有信息
    @RequestMapping("select1")
    public void select1(){
        System.out.println(service.getAll());
    }


    //查询id为固定数字的数据
    @RequestMapping("select2")
    public void select2(User user){

        System.out.println(service.getId(user));
    }

    //修改id=3的 name=提莫儿 age=20 sex=女
    @RequestMapping("update1")
    public void update1( User user){

        service.update1(user);

    }
    //修改name=提莫的    age=20 sex=女
    @RequestMapping("update2")
    public void update2( User user){

        service.update2(user);

    }
    //从网页端添加数据id=10 name=伽罗 sex=女 age= 10
    @RequestMapping("add")
    public void add( User user){

        service.add(user);

    }
    //删除数据，根据id来删除
    @RequestMapping("delete")
    public void delete(User user){

        service.delete(user);

    }

}
